package cn.wolfcode.web.controller;

import cn.wolfcode.common.web.Result;
import cn.wolfcode.domain.SeckillProduct;
import cn.wolfcode.domain.SeckillProductVo;
import cn.wolfcode.service.ISeckillProductService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;


@RestController
@RequestMapping("/seckillProduct")
@Slf4j
public class SeckillProductController {
    @Autowired
    private ISeckillProductService seckillProductService;



    @RequestMapping("/selectByTime")
    public Result<List<SeckillProductVo>> selectByTime(@RequestParam("time") Integer time){
        if (time!=null){
            List<SeckillProductVo> list= seckillProductService.selectByTime(time);
            return Result.success(list);
        }
        return null;
    }
    @RequestMapping("/queryByTime")
    public Result<List<SeckillProductVo>> queryByTime(@RequestParam("time") Integer time){
        if (time!=null){
            List<SeckillProductVo> list= seckillProductService.queryByTime(time);
            return Result.success(list);
        }
        return null;
    }
    @RequestMapping("/find")
    public Result<SeckillProductVo> find(@RequestParam("time") Integer time,@RequestParam("seckillId") Long seckillId){
        if (time!=null&&seckillId!=null){
            SeckillProductVo productVo= seckillProductService.find(time,seckillId);
            return Result.success(productVo);
        }
        return null;
    }


}
